package Negocio;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import Persistencia.PersistirDados;




@SuppressWarnings("unused")
public class FachadaSistema implements ISistema{

	private Departamento  departamento=new Departamento();;

	/* (non-Javadoc)
	 * @see Negocio.ISistema#cadastraProf(java.lang.String, java.lang.String)
	 */
	@Override
	public void cadastraProf(String nome, String matricula) {

		this.departamento.cadastraProf(nome, matricula);

	}

	/* (non-Javadoc)
	 * @see Negocio.ISistema#addDisciplina(Negocio.Disciplina)
	 *//*
        @Override
        public void addDisciplina(Disciplina disciplina){
                Turma turma= new Turma();
                turma.addDisciplina(disciplina);
        }
	  */
	/* (non-Javadoc)
	 * @see Negocio.ISistema#ListarProfessorDepart()
	 */
	@Override
	public List<Professor> ListarProfessorDepart(){

		List<Professor> professores= departamento.getListaProf();

		return professores;


	}

	@Override
	public void cadastrarDisciplina(String nome, String codigo,List<Professor> professor) throws FileNotFoundException, IOException {
		this.departamento.cadastraDisciplina(nome, codigo, professor);

	}

	@Override
	public List<Disciplina> ListarDisciplina() throws FileNotFoundException, IOException, ClassNotFoundException {
		List<Disciplina> listdisciplinas= new LinkedList<Disciplina>();
		listdisciplinas=PersistirDados.recuperarDisciplina();

		return (List<Disciplina>) listdisciplinas;

	}

	public boolean login(String nome, String maticula) throws FileNotFoundException, IOException, ClassNotFoundException {
		List<Professor> prof= new LinkedList<Professor>();
		prof=PersistirDados.recuperaUsandoArquivos();

		for(Professor p:prof){

			if(p.getNome().equalsIgnoreCase(nome)&&p.getMatricula().equalsIgnoreCase(maticula))


				return true;
		}
		return false;

	}

	@Override
	public Professor ListarProfessor(String nome, String maticula) throws FileNotFoundException, IOException, ClassNotFoundException {
		List<Professor> prof= new LinkedList<Professor>();
		prof=PersistirDados.recuperaUsandoArquivos();

		for(Professor p:prof){

			if(p.getNome().equalsIgnoreCase(nome)&&p.getMatricula().equalsIgnoreCase(maticula))


				return p;

		}
		return null;
	}

	@Override
	public String mostrarDisciplinas()  {	
		return departamento.mostrarDisciplinasDepartamento();
	}




	public String[] listaDisciplinas() throws FileNotFoundException, IOException, ClassNotFoundException{
		
		List<Disciplina> d=new LinkedList<Disciplina>();
		d=PersistirDados.recuperarDisciplina();
	
		String disc[]={"","","","","","","",""};

		for(int i=0;i<d.size();){
			 
			disc[i]=(String) d.get(i).getNome();	
		
		return disc;
		
		}
		return null;
	}

	@Override
	public void cadastrarDisciplinaProxSemestre(Disciplina disciplina) {
		
		
	}






}